import { useState } from "react"
import { Button } from 'antd-mobile'

interface SonProps {
  getMsg?: (msg: string) => void
}

function Son(props: SonProps) {
  const { getMsg } = props
  const clickHandler = () => {
    getMsg?.('this is msg')
  }
  return (
    <button onClick={clickHandler}>点我</button>
  )
}

function App() {
  const [value, setValue] = useState(false)
  return (
    <>
      <div>
        <Button color="success">Click</Button>
        <p onClick={() => setValue(!value)}><button>{value ? 'true' : 'false'}</button></p>
        <Son getMsg={(msg) => console.log(msg)} />
      </div>
    </>
  )
}

export default App
